﻿using B.S.Filtration.Write.Api.Application.Command.PowerCommand;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using B.S.Filtration.ErrorCode;

namespace B.S.Filtration.Write.Api.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class PowerController : ControllerBase
    {
        private readonly IMediator mediator;

        public PowerController(IMediator mediator)
        {
            this.mediator = mediator;
        }

        /// <summary>
        /// 添加动力信息
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIResult<int>> CraetePower(CreatePowerCommand request)
        {
            return await mediator.Send(request);
        }

        /// <summary>
        /// 删除动力信息
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIResult<int>> DelPower(DelPowerCommand request)
        {
            return await mediator.Send(request);
        }

        /// <summary>
        /// 修改动力信息
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIResult<int>> UpdPower(UpdPowerCommand request)
        {
            return await mediator.Send(request);
        }
    }
}
